Skip to content

fix(caldav): Expand recurring events for principal calendar search#60766

Open
kesselb wants to merge 10 commits into
masterfrom
bug/noid/expand-unified-search
Open

fix(caldav): Expand recurring events for principal calendar search#60766
kesselb wants to merge 10 commits into
masterfrom
bug/noid/expand-unified-search

Conversation

@kesselb

@kesselb kesselb commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Expand recurring events when searching for events through unified search.

STR:

  • Create a new event yesterday two years ago (2024-05-26)
  • Add a yearly recurrence
  • Open unified search, add filter for events and last 30 days
  • Search for the event by title

Main: Event 2024-05-26 is shown
Here: Event 2026-05-26 is shown

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@kesselb kesselb added this to the Nextcloud 35 milestone May 27, 2026
@kesselb kesselb requested a review from Copilot May 27, 2026 10:25
@kesselb kesselb self-assigned this May 27, 2026
@kesselb kesselb added the bug label May 27, 2026
@kesselb kesselb added the 2. developing Work in progress label May 27, 2026
@kesselb kesselb requested a review from a team as a code owner May 27, 2026 10:26
@kesselb kesselb requested review from CarlSchwan, artonge, leftybournes and salmart-dev and removed request for a team May 27, 2026 10:26
@kesselb

kesselb commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable34

@kesselb

kesselb commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable33

@kesselb

kesselb commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread apps/dav/lib/CalDAV/CalDavBackend.php Outdated
Comment on lines +2436 to +2440
// Expand recurrences if an explicit time range is requested
if ($calendarData instanceof VCalendar && isset($start, $end)) {
$calendarData = $calendarData->expand($start, $end);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

So I understand the need to have the expanded events, but I think this is the wrong place to implement this. The back end is a storage interface and it should handle only the storing and retrieval of data, not the manipulation of the data. This should be done by the caller, as the expansion is specifically needed by the event search and not all other callers.

Also, the expand function is highly inefficient, there can be hundreds or event thousands of event returned from the original search, this now forces the creation of event more new instances of those events before returning.

I would recommend doing this in the search provider and using the EventReader, which is way more efficient at finding the the next occurrence of a recurring event.

https://github.com/nextcloud/server/blob/master/apps/dav/lib/CalDAV/EventReader.php

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first iteration did the expansion in the EventSearchProvider, so that works too. Christoph and I discussed it recently. CalDavBackend.search (the one for a single calendar) also does the expansion, and adjusting searchPrincipalUri ensures that both methods behave more similarly than before.

That said, both approaches make sense to me. Can you and @ChristophWurst figure that out? I don't have a strong preference either way.

@SebastianKrupinski

Copy link
Copy Markdown
Contributor

I approved by mistake! It was meant to be a comment!

@kesselb kesselb force-pushed the bug/noid/expand-unified-search branch from 5c8045f to cf432ac Compare June 9, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants